﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;

namespace JsonDataWebApplication
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "DataService" in code, svc and config file together.
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    public class DataService : IDataService
    {
        public Person GetOnePerson(string id)
        {
            // lookup person with the requested id 
            return new Person()
            {
                id = Convert.ToInt32(id),
                name = "Leo Messi" + DateTime.Now
            };
        }

        public Person[] GetAllPeople()
        {
            var tempList = new List<Person>();

            for (int i = 0; i < 10; i++)
            {
                var p = new Person()
                {
                    id = Convert.ToInt32(i),
                    name = "Hellow" + i + " " + DateTime.Now
                };
                tempList.Add(p);
            }
            return tempList.ToArray();
        }
    }
}
